(function($) {
	$.fn.mouseslide = function(options) {
		var defaults = {
			height: '312px'
		};
		var opts = $.extend(defaults, options);
		var expands = 1;
		var self = this;
		var galleryWidthArr = [];
		var Touchable = Modernizr.touch || window.navigator.userAgent.indexOf("Touch") != -1;
		if(Touchable){
			self.css({'overflow-x':'auto','overflow-y':'auto'});
		} else {
			self.css({'overflow-x':'hidden','overflow-y':'auto'});
		}
		self.children().css('height', opts.height);
		
		self.children().each(function(i){
			var galleryWidth = 0 ;			
			$(this).children().each(function(index) {
				galleryWidth = galleryWidth + $(this).outerWidth(true);
				
			})
			galleryWidthArr[i] = galleryWidth;			
		});
		self.children().css({"width": galleryWidthArr.max()});
		if(!Touchable){
			$(this).parent().on('mousemove',function(e) {
				var x = e.pageX - this.offsetLeft;
				var calc = (self.children().width() - self.width()) / self.width();
				var left = x * calc;
				var right = (self.width() - x) * calc;
				self.scrollLeft(left);
				if (opts.mirror) {
					self.next().scrollLeft(right)
				}
			});
		}
	}
})(jQuery);